<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="../../include/easyui.jsp" %>
<%@ include file="../../include/pGrid.jsp" %>
<title>组织管理</title>
<script>
	$(function(){
		/*标记列表为树形*/
		p.isTreeGrid = true;
		p.dataGrid = $(p.dataGrid).treegrid($.extend({},p.dataGridParam,{
			columns: [[
		         {field:"orgName",			width:180,	title:"组织名称" }
		         ,{field:"orgType",			width:80,	title:"分类" }
		         ,{field:"orgNo",				width:180,	title:"组织编码" }
		         ,{field:"orgLeaderName",	width:120,	title:"负责人"}
	             ,{field:"orgMembersName",	width:250,	title:"成员"}
		         ,{field:"orgOrder",		width:100,	title:"组织排序"}
		         ,{field:"createrName",		width:120, 	title : "创建人" }
				 ,{field:"createTime", 		width:130, 	title : "创建时间" }
			]],
			sortName:"orgOrder",
			sortOrder:"asc",
			idField: "treeId", 
			treeField: "orgName",
			queryParams:{isTreeGrid:"true", treeId:"id", treePid:"parentId" }
		}));
		
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var id = $(this).attr("motion_code");
			switch(id){
				case "01":
					var rows = p.dataGrid.datagrid('getSelections'), len = rows.length;
					var data = {parentName : "无" }; 
					if(len>0){
						data = { parentId: rows[0].id || "" , parentName: rows[0].orgName || "无"};
					}
					p.gridAdd({ title : "组织新增", width : 600, height : 320,data: data });
					break;
				case "02":
					/*var rows = p.dataGrid.datagrid('getSelections'), len = rows.length;
					var data = {porgName : "无" }; 
					if(len>0){
						data =  { porgName: rows[0].orgName || "无"};
					}*/
					p.gridModify({title : "组织编辑" ,width : 600, height : 320 });
					break;
				case "03":
					var rows = p.dataGrid.treegrid('getSelections');
					if(rows.length>0 && rows[0].orgNo=='0000'){
						p.tip({msg: '根节点不允许删除！'});
						return false;
					}
					p.gridDelete({});
					break;
				case "05":
					p.gridQuery();
					break;
				default: 
					p.tip({msg: $(this).text() +'未添加响应事件！'}); break;
			}
		});
	});
</script>
</head>
<body   class="easyui-layout">
<!-- 但行高度33px，多行时 33乘以行数  -->
	<div  id="querybar"  data-options="region:'north',split:false,border:false" style="height:33px;">
		<div class="easyui-panel" data-options="fit:true,border:false"  >
			<form id="queryForm">
				<input type="hidden" name="className" value="${className}" />
				<div style="margin-top:5px;margin-left:10px;float:left;">
					<input class="easyui-textbox" name="orgName" style="width:240px;" data-options="label:'组织名称:',required:false" />
					<input type="hidden" name="orgName_searchType" value="like" />
				</div>
				<div style="margin-top:5px;margin-left:10px;float:left;">
					<input class="easyui-textbox" name="orgNo" style="width:240px;" data-options="label:'组织编码:',required:false" />
					<input type="hidden" name="orgNo_searchType" value="like" />
				</div>
			</form>		
		</div>
	</div>  

	<!-- 工具栏 -->
	<div id="toolbar" class="easyui-panel" style="padding:3px;"></div>
	
	<!-- 表格 --> 
	<div region="center" border="false">
		<table id="dataGrid"></table>
	</div>
</body>
</html>